﻿@{
    
    var _url = ViewBag.ActiveUrl as ForumUrl;

    var _roles = ViewBag.List as List<Role>;
        
}
@model Role
<div class="site-block">
    <div class="header">
        @_url.Title
    </div>
    <form action="@_url.Url" class="ajax">
    @Html.HiddenFor(x => Model.RoleId)
    @Html.Hidden("returnUrl",_url.Url)
    <div class="site-block-content">
        <table>
            <tr>
                <td class="w25">
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "ROLE_NAME")
                </td>
                <td>
                    @Html.TextBoxFor(x => Model.RoleName, new { @class = "input {validate:{required:1}}" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "CssClass")
                </td>
                <td>
                    @Html.TextBoxFor(x => Model.CssClass, new { @class = "input" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "ALLOW_LOGIN")
                </td>
                <td>
                    @Html.RadioButtonGroup("AllowLogin", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.AllowLogin, new { @class = "radio-group-panel" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "IsAutoStart")
                </td>
                <td>
                    @Html.RadioButtonGroup("IsAutoStart", (List<SelectItem>)ViewBag.YesNo, Model != null && Model.IsAutoStart, new { @class = "radio-group-panel" })
                </td>
            </tr>
            @*----------------------------------------Admin Permissions-----------------------------*@
            <tr>
                <td class="caption" colspan="2">
                    @ForumContext.GetText(LanguageSection.ROLE_MANAGER, "ADMIN_PERMISSIONS")
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "IsAdmin")
                </td>
                <td>
                    @Html.RadioButtonGroup("IsAdmin", (List<SelectItem>)ViewBag.YesNo, Model != null && Model.IsAdmin, new { @class = "radio-group-panel" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "SUPER_MODERATOR")
                </td>
                <td>
                    @Html.RadioButtonGroup("IsSuperModerator", (List<SelectItem>)ViewBag.YesNo, Model != null && Model.IsSuperModerator, new { @class = "radio-group-panel" })
                </td>
            </tr>
            @*----------------------------------------POST_OPTIONS-----------------------------*@
            <tr>
                <td class="caption" colspan="2">
                    @ForumContext.GetText(LanguageSection.ROLE_MANAGER, "POST_OPTIONS")
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "ALLOW_NEW_TOPIC")
                </td>
                <td>
                    @Html.RadioButtonGroup("PostNewTopics", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.Permissions.PostNewTopics, new { @class = "radio-group-panel" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "ALLOW_NEW_REPLY")
                </td>
                <td>
                    @Html.RadioButtonGroup("PostReplyToTopics", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.Permissions.PostReplyToTopics, new { @class = "radio-group-panel" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "ALLOW_NEW_POLL")
                </td>
                <td>
                    @Html.RadioButtonGroup("PostNewPolls", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.Permissions.PostNewPolls, new { @class = "radio-group-panel" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "ALLOW_NEW_REPLY_TO_POLL")
                </td>
                <td>
                    @Html.RadioButtonGroup("PostReplyToPolls", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.Permissions.PostReplyToPolls, new { @class = "radio-group-panel" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "ALLOW_POST_WITHIN_LOCKED_FORUM")
                </td>
                <td>
                    @Html.RadioButtonGroup("PostWithinLockedForums", (List<SelectItem>)ViewBag.YesNo, Model != null && Model.Permissions.PostWithinLockedForums, new { @class = "radio-group-panel" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "ALLOW_POST_WITHIN_LOCKED_TOPIC")
                </td>
                <td>
                    @Html.RadioButtonGroup("PostWithinLockedTopics", (List<SelectItem>)ViewBag.YesNo, Model != null && Model.Permissions.PostWithinLockedTopics, new { @class = "radio-group-panel" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "ALLOW_STICKY_POSTS")
                </td>
                <td>
                    @Html.RadioButtonGroup("AllowStickyPosts", (List<SelectItem>)ViewBag.YesNo, Model != null && Model.Permissions.AllowStickyPosts, new { @class = "radio-group-panel" })
                </td>
            </tr>
            @*----------------------------------------EDIT_OPTIONS-----------------------------*@
            <tr>
                <td class="caption" colspan="2">
                    @ForumContext.GetText(LanguageSection.ROLE_MANAGER, "EDIT_OPTIONS")
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "ALLOW_EDIT_OWN_TOPIC")
                </td>
                <td>
                    @Html.RadioButtonGroup("EditOwnTopics", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.Permissions.EditOwnTopics, new { @class = "radio-group-panel" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "ALLOW_EDIT_OWN_POST")
                </td>
                <td>
                    @Html.RadioButtonGroup("EditOwnPosts", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.Permissions.EditOwnPosts, new { @class = "radio-group-panel" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "ALLOW_EDIT_LOCKED_TOPIC")
                </td>
                <td>
                    @Html.RadioButtonGroup("EditLockedTopics", (List<SelectItem>)ViewBag.YesNo, Model != null && Model.Permissions.EditLockedTopics, new { @class = "radio-group-panel" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "UPDATE_LAST_EDITED_BY")
                </td>
                <td>
                    @Html.RadioButtonGroup("UpdateLastEditedBy", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.Permissions.UpdateLastEditedBy, new { @class = "radio-group-panel" })
                </td>
            </tr>
            @*----------------------------------------DEL_OPTIONS-----------------------------*@
            <tr>
                <td class="caption" colspan="2">
                    @ForumContext.GetText(LanguageSection.ROLE_MANAGER, "DEL_OPTIONS")
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "ALLOW_DEL_OWN_TOPIC")
                </td>
                <td>
                    @Html.RadioButtonGroup("DeleteOwnTopics", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.Permissions.DeleteOwnTopics, new { @class = "radio-group-panel" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "ALLOW_DEL_OWN_POST")
                </td>
                <td>
                    @Html.RadioButtonGroup("DeleteOwnPosts", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.Permissions.DeleteOwnPosts, new { @class = "radio-group-panel" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "ALLOW_DEL_LOCKED_POST")
                </td>
                <td>
                    @Html.RadioButtonGroup("DeleteLockedPosts", (List<SelectItem>)ViewBag.YesNo, Model != null && Model.Permissions.DeleteLockedPosts, new { @class = "radio-group-panel" })
                </td>
            </tr>
            @*----------------------------------------MODERATION_OPTIONS-----------------------------*@
            <tr>
                <td class="caption" colspan="2">
                    @ForumContext.GetText(LanguageSection.ROLE_MANAGER, "MODERATION_OPTIONS")
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "ALWAYS_POST_APRROVED")
                </td>
                <td>
                    @Html.RadioButtonGroup("AlwaysPostAprroved", (List<SelectItem>)ViewBag.YesNo, Model != null && Model.Permissions.AlwaysPostAprroved, new { @class = "radio-group-panel" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "QUEUE_WHEN_EDITED")
                </td>
                <td>
                    @Html.RadioButtonGroup("QueueEdited", (List<SelectItem>)ViewBag.YesNo, Model != null && Model.Permissions.QueueEdited, new { @class = "radio-group-panel" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "SEND_POST_APPROVED_EMAIL")
                </td>
                <td>
                    @Html.RadioButtonGroup("SendPostApprovedEmail", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.Permissions.SendPostApprovedEmail, new { @class = "radio-group-panel" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "ALLOW_POST_REPORTS")
                </td>
                <td>
                    @Html.RadioButtonGroup("AllowPostReports", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.Permissions.AllowPostReports, new { @class = "radio-group-panel" })
                </td>
            </tr>
            @*----------------------------------------TOPIC FORUM OPTIONS-----------------------------*@
            <tr>
                <td class="caption" colspan="2">
                    @ForumContext.GetText(LanguageSection.ROLE_MANAGER, "TOPIC_FORUM_OPTIONS")
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "ALLOW_READ_FORUMS")
                </td>
                <td>
                    @Html.RadioButtonGroup("AllowReadForums", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.Permissions.AllowReadForums, new { @class = "radio-group-panel" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "ALLOW_READ_TOPICS")
                </td>
                <td>
                    @Html.RadioButtonGroup("AllowReadTopics", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.Permissions.AllowReadTopics, new { @class = "radio-group-panel" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "SEND_TOPICS_VIA_EMAIL")
                </td>
                <td>
                    @Html.RadioButtonGroup("SendTopicsViaEmail", (List<SelectItem>)ViewBag.YesNo, Model != null && Model.Permissions.SendTopicsViaEmail, new { @class = "radio-group-panel" })
                </td>
            </tr>
            @*----------------------------------------EMAIL_OPTIONS-----------------------------*@
            <tr>
                <td class="caption" colspan="2">
                    @ForumContext.GetText(LanguageSection.ROLE_MANAGER, "EMAIL_OPTIONS")
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "ALLOW_SEND_EMAIL")
                </td>
                <td>
                    @Html.RadioButtonGroup("AllowSendEmail", (List<SelectItem>)ViewBag.YesNo, Model != null && Model.Permissions.AllowSendEmail, new { @class = "radio-group-panel" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "MAX_EMAIL_RECIPIENTS")
                </td>
                <td>
                    @Html.TextBox("MaxEmailRecipients", Model != null ? Model.Permissions.MaxEmailRecipients : 5, new { @class = "input {validate:{required:1,digits:1}}", style = "width:100px" })
                </td>
            </tr>
            @*----------------------------------------SUBCRIBE_OPTIONS-----------------------------*@
            <tr>
                <td class="caption" colspan="2">
                    @ForumContext.GetText(LanguageSection.ROLE_MANAGER, "SUBCRIBE_OPTIONS")
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "SUBCRIBE_TO_FORUMS")
                </td>
                <td>
                    @Html.RadioButtonGroup("SubscribeToForums", (List<SelectItem>)ViewBag.YesNo, Model != null && Model.Permissions.SubscribeToForums, new { @class = "radio-group-panel" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "SUBCRIBE_TO_TOPICS")
                </td>
                <td>
                    @Html.RadioButtonGroup("SubscribeToTopics", (List<SelectItem>)ViewBag.YesNo, Model != null && Model.Permissions.SubscribeToTopics, new { @class = "radio-group-panel" })
                </td>
            </tr>
            @*----------------------------------------SEARCH_OPTIONS-----------------------------*@
            <tr>
                <td class="caption" colspan="2">
                    @ForumContext.GetText(LanguageSection.ROLE_MANAGER, "SEARCH_OPTIONS")
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "ALLOW_SEARCH")
                </td>
                <td>
                    @Html.RadioButtonGroup("AllowSearch", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.Permissions.AllowSearch, new { @class = "radio-group-panel" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "MAX_SEARCH_RESULTS")
                </td>
                <td>
                    @*@Html.TextBoxFor(x => Model.Permissions.MaxSearchResults, new { @class = "input {validate:{required:1,digits:1}}", style = "width:100px" })*@
                    @Html.TextBox("MaxSearchResults", Model != null ? Model.Permissions.MaxSearchResults : 500, new { @class = "input {validate:{required:1,digits:1}}", style = "width:100px" })
                    @*@Html.RadioButtonGroup("AllowSearch", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.Permissions.MaxSearchResults, new { @class = "radio-group-panel" })*@
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "SEARCH_RESULT_PER_PAGE")
                </td>
                <td>
                    @*@Html.TextBoxFor(x => Model.Permissions.SearchResultsPerPage, new { @class = "input {validate:{required:1,digits:1}}", style = "width:100px" })*@
                    @Html.TextBox("SearchResultsPerPage", Model != null ? Model.Permissions.SearchResultsPerPage : 25, new { @class = "input {validate:{required:1,digits:1}}", style = "width:100px" })
                </td>
            </tr>
            @*----------------------------------------ATTACH_OPTIONS-----------------------------*@
            <tr>
                <td class="caption" colspan="2">
                    @ForumContext.GetText(LanguageSection.ROLE_MANAGER, "ATTACH_OPTIONS")
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "MAX_UPLOAD_STORAGE")
                </td>
                <td>
                    @*@Html.TextBoxFor(x => Model.Permissions.MaxUploadStorage, new { @class = "input {validate:{required:1,digits:1}}", style = "width:100px" })*@
                    @Html.TextBox("MaxUploadStorage", Model != null ? Model.Permissions.MaxUploadStorage : 10, new { @class = "input {validate:{required:1,digits:1}}", style = "width:100px" })
                    Mb
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "ALLOW_FILE_TYPES")
                </td>
                <td>
                    @*@Html.TextBoxFor(x => Model.Permissions.AllowFileTypes, new { @class = "input" })*@
                    @Html.TextBox("AllowFileTypes", Model != null ? Model.Permissions.AllowFileTypes : "*", new { @class = "input" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.ROLE_MANAGER, "ALLOW_DOWNLOAD_ATTACH")
                </td>
                <td>
                    @Html.RadioButtonGroup("AllowDownloadAttach", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.Permissions.AllowDownloadAttach, new { @class = "radio-group-panel" })
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    @Html.Button(ButtonType.Submit, (string)ViewBag.ButtonText, new { @class = "ui-button" })
                    @Html.Button(ButtonType.Button, ForumContext.GetText(LanguageSection.GLOBAL, "Cancel"), new { @class = "ui-button", @onclick = string.Format("$.MvcForum.jump('{0}')", _url.Url) })
                </td>
            </tr>
        </table>
    </div>
    </form>
</div>


@if (_roles != null && _roles.Count > 0)
{
    
    <form action="@_url.Url" id="_fl">
    @Html.Hidden("act", "del")
    <div class="gridview white-t">
        <div class="head">
            @ForumContext.GetText(LanguageSection.ROLE_MANAGER, "ROLE_LIST")
        </div>
        <table class="datatable">
            <tr>
                <th class="header w5" scope="col">
                    <input type='checkbox' onclick='$.MvcForum.toggleCheckbox(this.checked)' />
                </th>
                <th class="header" scope="col">
                    @ForumContext.GetText(LanguageSection.ROLE_MANAGER, "ROLE_NAME_HEAD")
                </th>
                <th class="header" scope="col">
                    @ForumContext.GetText(LanguageSection.ROLE_MANAGER, "ISADMIN_HEAD")
                </th>
                <th class="header" scope="col">
                    @ForumContext.GetText(LanguageSection.ROLE_MANAGER, "ISSUPERMOD_HEAD")
                </th>
                <th class="header" scope="col">
                    @ForumContext.GetText(LanguageSection.ROLE_MANAGER, "IS_AUTO_START_HEAD")
                </th>
                <th class="header" scope="col">
                    @ForumContext.GetText(LanguageSection.GLOBAL, "OPTIONS")
                </th>
            </tr>
            @foreach (var f in _roles)
            {
                <tr class="row" id="@string.Format("row_{0}", f.RoleId)">
                    <td class="center">
                        <input type="checkbox" name="Ids" value="@f.RoleId" class="selected" />
                    </td>
                    <td class="@f.CssClass">
                        @f.RoleName
                    </td>
                    <td class="center width10">
                        @f.IsAdmin
                    </td>
                    <td class="center width10">
                        @f.IsSuperModerator
                    </td>
                    <td class="center width10">
                        @f.IsAutoStart
                    </td>
                    <td class="center width10">                        
                        @Html.Link(string.Format("{0}?Id={1}", _url.Url, f.RoleId), "", new { @class = "ui-button icon-16 edit" })
                    </td>
                </tr>
                
            }
        </table>
    </div>
    <div class="white-t">
        @Html.Link("javascript:void(0)", "", new { @onclick = "$.KoolBox.confirm('" + ForumContext.GetText(LanguageSection.MESSAGES, "DELETE_CONFIRM") + "',{title:'Confirm'},function(r){if(r){$.MvcForum.ajaxSubmit('_fl')}})", @class = "ui-button icon-16 del" })
    </div>
    </form>
    
}